#ifndef SINGLELOG_H
#define SINGLELOG_H

#include <QObject>
#include <qtimer.h>
#include <QMutex>
//日志级别
enum {LEVEL_ERROR = 1,LEVEL_WARN =2,LEVEL_NORMAL=3};
#define HERE   __FILE__,__FUNCTION__,__LINE__

class SingleLog : public QObject
{
    Q_OBJECT
public:
    static SingleLog* getInstance(){
        if(!m_instance)
        {
            m_instance = new SingleLog();
        }
        return m_instance;
    }

    void Init();
    void Printf(int level,const QString strConnect);
    void SPrintf(int level, const char* file, const char* func, int lineNum, const char* format, ...);
private:
    void Del();

private:
    static SingleLog * m_instance;
    explicit SingleLog(QObject *parent = 0);
    ~SingleLog();

    QMutex m_Mutex;
    QString m_currenDir;
    int MaxFileSize;
    int MaxSaveTime;
    int PrintLevel;
    QString LogDir;
    QString LogFileName;
    QString lastContent;
};

#endif // SINGLELOG_H
